package create.builder.demo.meal;

import create.builder.demo.food.Item;

import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @AUTHOR LYF
 * @DATE 2022/3/17
 * @VERSION 1.0
 * @DESC
 */
public class Meal {
    ArrayList<Item> items=new ArrayList();
    void addItem(Item item){
        items.add(item);
    }
    int getCost(){
        //int cost = 0;
        AtomicInteger cost = new AtomicInteger(0);
        items.forEach(i->{
            cost.getAndAdd(i.price());
        });
       return cost.get();
    }
    public void showItems(){
        items.forEach(u->{
            System.out.println(u+"--");
        });
    }


}
